import tkinter as tk

class App:
    def __init__(self, master):
        self.master = master
        self.label_NTC = tk.Label(master, text="NTC Choose: " + "None")
        self.label_NTC.pack(anchor='w')

        self.radio_var1 = tk.IntVar()  #NTC选择 10K 100K 50K

        radio_10K = tk.Radiobutton(master, text="10K", variable=self.radio_var1, value=1, command=self.radio_selected_NTC)
        radio_100K = tk.Radiobutton(master, text="100K", variable=self.radio_var1, value=2, command=self.radio_selected_NTC)
        radio_50K = tk.Radiobutton(master, text="50K", variable=self.radio_var1, value=3, command=self.radio_selected_NTC)

        radio_10K.pack(side=tk.TOP,anchor='w')# 使用side=LEFT使按钮水平排列
        radio_100K.pack(side=tk.TOP,anchor='w')# 继续添加到同一行
        radio_50K.pack(side=tk.TOP,anchor='w')# 继续添加到同一行

        self.label_connect = tk.Label(master, text="NTC Postion: " + "None")
        self.label_connect.pack(anchor='w')

        self.radio_var2 = tk.IntVar()   #上下选择 0-GND 1-VCC

        radio_VCC = tk.Radiobutton(master, text="VCC", variable=self.radio_var2, value=1, command=self.radio_selected_connect)
        radio_GND = tk.Radiobutton(master, text="GND", variable=self.radio_var2, value=2, command=self.radio_selected_connect)

        radio_VCC.pack(side=tk.TOP,anchor='w')# 使用side=LEFT使按钮水平排列
        radio_GND.pack(side=tk.TOP,anchor='w')# 继续添加到同一行

        # 创建一个标签，用于显示文本框的内容
        self.label = tk.Label(master, text="RES Choose: None")
        self.label.pack(anchor='w')

        # 创建一个文本框
        self.entry = tk.Entry(master)
        self.entry.pack(side=tk.TOP,anchor='w')

        # 创建一个按钮，当点击时将获取文本框的内容
        get_button = tk.Button(master, text="Enter",command=self.get_input_res)
        get_button.pack(side=tk.TOP,anchor='w')

        # 创建一个按钮，当点击时将生成csv文件并保存
        get_button = tk.Button(master, text="Build CSV",command=self.save_csv)
        get_button.pack(side=tk.TOP,anchor='w')
        
    def radio_selected_NTC(self):
        if self.radio_var1.get() == 1:
            self.label_NTC.config(text="NTC Choose: " + "10K")
        elif self.radio_var1.get() == 2:
            self.label_NTC.config(text="NTC Choose: " + "100K")
        elif self.radio_var1.get() == 3:
            self.label_NTC.config(text="NTC Choose: " + "50K")

    def radio_selected_connect(self):
        if self.radio_var2.get() == 1:
            self.label_connect.config(text="NTC Postion: " + "VCC")
        elif self.radio_var2.get() == 2:
            self.label_connect.config(text="NTC Postion: " + "GND")

    def get_input_res(self):
        if(self.entry.get() == ""):
            self.label.config(text="RES Choose: None")
        else:
            user_input = self.entry.get()  # 获取文本框的内容
            self.label.config(text="RES Choose: " + user_input + "KΩ")  # 将获取的内容显示在Label控件中

    def save_csv(self):
        pass



root = tk.Tk()
app = App(root)
root.title("NTC-ADC Converter")
root.geometry("150x300")
root.minsize(150, 300)
root.maxsize(150, 300)
root.mainloop()